﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BUS
{
    public class PersonalBUS
    {
        public static DataTable LayTatCaKHCaNhan()
        {
            return DAO.PersonalDAO.LayTatCaKHCaNhan();
        }

        public static DataTable LayKHCaNhanTheoNhanVien(Int32 MaNV)
        {
            return DAO.PersonalDAO.LayKHCaNhanTheoNhanVien(MaNV);
        }

        public static int ThemKHCaNhan(Entity.Personal kh)
        {
            if(kh.Ten == "" || kh.NgaySinh >= DateTime.Now || kh.SoNamLamViec < 0 || kh.SoNguoiPhuThuoc < 0 || kh.ThuNhap < 0 || 
               kh.ThuNhapGiaDinh < 0 || kh.DienThoai == "" || kh.CMND == "" || kh.DiaChi == "" || kh.HanMuc < 0 ||
               kh.HoKhau == "" || kh.HonNhan == "" || kh.Ma == "" || kh.MaSoThue == "" || kh.NgheNghiep == "" || kh.NoiLamViec == "" ||
               kh.TrinhDo == "")
                throw new Exception("Thông tin chưa chính xác!!!");
            return DAO.PersonalDAO.ThemKHCaNhan(kh);
        }

        public static int CapNhatKHCaNhan(Entity.Personal kh)
        {
            if (kh.Ten == "" || kh.NgaySinh >= DateTime.Now || kh.SoNamLamViec < 0 || kh.SoNguoiPhuThuoc < 0 || kh.ThuNhap < 0 ||
               kh.ThuNhapGiaDinh < 0 || kh.DienThoai == "" || kh.CMND == "" || kh.DiaChi == "" || kh.HanMuc < 0 ||
               kh.HoKhau == "" || kh.HonNhan == "" || kh.Ma == "" || kh.MaSoThue == "" || kh.NgheNghiep == "" || kh.NoiLamViec == "" ||
               kh.TrinhDo == "")
                throw new Exception("Thông tin chưa chính xác!!!");
            return DAO.PersonalDAO.CapNhatKHCaNhan(kh);
        }

        public static int XoaKHCaNhan(String kh)
        {
            return DAO.PersonalDAO.XoaKHCaNhan(kh);
        }
    }
}
